{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Varying the Classification Threshold in Logistic Regression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "data_web_address = \"https://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data\"\n",
    "column_names = ['pregnancy_x', \n",
    "                'plasma_con', \n",
    "                'blood_pressure', \n",
    "                'skin_mm', \n",
    "                'insulin', \n",
    "                'bmi', \n",
    "                'pedigree_func', \n",
    "                'age', \n",
    "                'target']\n",
    "\n",
    "feature_names = column_names[:-1]\n",
    "all_data = pd.read_csv(data_web_address , names=column_names)\n",
    "all_data.head()\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "X = all_data[feature_names]\n",
    "y = all_data['target']\n",
    "\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=7,stratify=y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "lr = LogisticRegression()\n",
    "lr.fit(X_train,y_train)\n",
    "\n",
    "y_pred = lr.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_pred_proba = lr.predict_proba(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.87110309,  0.12889691],\n",
       "       [ 0.83996356,  0.16003644],\n",
       "       [ 0.81821721,  0.18178279],\n",
       "       [ 0.73973464,  0.26026536],\n",
       "       [ 0.80392034,  0.19607966],\n",
       "       [ 0.97661331,  0.02338669],\n",
       "       [ 0.91417761,  0.08582239],\n",
       "       [ 0.69095568,  0.30904432],\n",
       "       [ 0.84737969,  0.15262031],\n",
       "       [ 0.42467393,  0.57532607],\n",
       "       [ 0.80527656,  0.19472344],\n",
       "       [ 0.4549751 ,  0.5450249 ],\n",
       "       [ 0.76046297,  0.23953703],\n",
       "       [ 0.78354755,  0.21645245],\n",
       "       [ 0.26617998,  0.73382002],\n",
       "       [ 0.92885146,  0.07114854],\n",
       "       [ 0.48230915,  0.51769085],\n",
       "       [ 0.7643201 ,  0.2356799 ],\n",
       "       [ 0.72843522,  0.27156478],\n",
       "       [ 0.97183494,  0.02816506],\n",
       "       [ 0.38376215,  0.61623785],\n",
       "       [ 0.37861048,  0.62138952],\n",
       "       [ 0.6990594 ,  0.3009406 ],\n",
       "       [ 0.63859007,  0.36140993],\n",
       "       [ 0.26278893,  0.73721107],\n",
       "       [ 0.68879542,  0.31120458],\n",
       "       [ 0.69872131,  0.30127869],\n",
       "       [ 0.9045281 ,  0.0954719 ],\n",
       "       [ 0.82250969,  0.17749031],\n",
       "       [ 0.20758421,  0.79241579],\n",
       "       [ 0.24260321,  0.75739679],\n",
       "       [ 0.38897084,  0.61102916],\n",
       "       [ 0.81471568,  0.18528432],\n",
       "       [ 0.62108183,  0.37891817],\n",
       "       [ 0.32054282,  0.67945718],\n",
       "       [ 0.86991644,  0.13008356],\n",
       "       [ 0.82651319,  0.17348681],\n",
       "       [ 0.26857901,  0.73142099],\n",
       "       [ 0.66391131,  0.33608869],\n",
       "       [ 0.59833094,  0.40166906],\n",
       "       [ 0.67990724,  0.32009276],\n",
       "       [ 0.85129105,  0.14870895],\n",
       "       [ 0.80091591,  0.19908409],\n",
       "       [ 0.8928416 ,  0.1071584 ],\n",
       "       [ 0.86069386,  0.13930614],\n",
       "       [ 0.73082065,  0.26917935],\n",
       "       [ 0.70134546,  0.29865454],\n",
       "       [ 0.52734599,  0.47265401],\n",
       "       [ 0.87942406,  0.12057594],\n",
       "       [ 0.82310419,  0.17689581],\n",
       "       [ 0.60841543,  0.39158457],\n",
       "       [ 0.39753653,  0.60246347],\n",
       "       [ 0.72735187,  0.27264813],\n",
       "       [ 0.70010972,  0.29989028],\n",
       "       [ 0.80337778,  0.19662222],\n",
       "       [ 0.88747584,  0.11252416],\n",
       "       [ 0.36371604,  0.63628396],\n",
       "       [ 0.89264394,  0.10735606],\n",
       "       [ 0.77558591,  0.22441409],\n",
       "       [ 0.78652908,  0.21347092],\n",
       "       [ 0.42926339,  0.57073661],\n",
       "       [ 0.78274945,  0.21725055],\n",
       "       [ 0.61795636,  0.38204364],\n",
       "       [ 0.93205076,  0.06794924],\n",
       "       [ 0.86908202,  0.13091798],\n",
       "       [ 0.67247153,  0.32752847],\n",
       "       [ 0.64660727,  0.35339273],\n",
       "       [ 0.32368679,  0.67631321],\n",
       "       [ 0.75561819,  0.24438181],\n",
       "       [ 0.42401027,  0.57598973],\n",
       "       [ 0.36781368,  0.63218632],\n",
       "       [ 0.77223135,  0.22776865],\n",
       "       [ 0.74186241,  0.25813759],\n",
       "       [ 0.40688799,  0.59311201],\n",
       "       [ 0.76021352,  0.23978648],\n",
       "       [ 0.26968892,  0.73031108],\n",
       "       [ 0.28185448,  0.71814552],\n",
       "       [ 0.81494147,  0.18505853],\n",
       "       [ 0.55420886,  0.44579114],\n",
       "       [ 0.88692289,  0.11307711],\n",
       "       [ 0.50924516,  0.49075484],\n",
       "       [ 0.30586986,  0.69413014],\n",
       "       [ 0.9424577 ,  0.0575423 ],\n",
       "       [ 0.92612512,  0.07387488],\n",
       "       [ 0.82972856,  0.17027144],\n",
       "       [ 0.5103314 ,  0.4896686 ],\n",
       "       [ 0.48158697,  0.51841303],\n",
       "       [ 0.8112139 ,  0.1887861 ],\n",
       "       [ 0.11172864,  0.88827136],\n",
       "       [ 0.81831086,  0.18168914],\n",
       "       [ 0.8394241 ,  0.1605759 ],\n",
       "       [ 0.91970777,  0.08029223],\n",
       "       [ 0.62090434,  0.37909566],\n",
       "       [ 0.91541163,  0.08458837],\n",
       "       [ 0.74942886,  0.25057114],\n",
       "       [ 0.32607859,  0.67392141],\n",
       "       [ 0.43841998,  0.56158002],\n",
       "       [ 0.40981508,  0.59018492],\n",
       "       [ 0.75985263,  0.24014737],\n",
       "       [ 0.50818767,  0.49181233],\n",
       "       [ 0.86774393,  0.13225607],\n",
       "       [ 0.86769043,  0.13230957],\n",
       "       [ 0.84431906,  0.15568094],\n",
       "       [ 0.72066548,  0.27933452],\n",
       "       [ 0.92898742,  0.07101258],\n",
       "       [ 0.79052971,  0.20947029],\n",
       "       [ 0.92680116,  0.07319884],\n",
       "       [ 0.50460946,  0.49539054],\n",
       "       [ 0.90308048,  0.09691952],\n",
       "       [ 0.61247278,  0.38752722],\n",
       "       [ 0.62901419,  0.37098581],\n",
       "       [ 0.90505436,  0.09494564],\n",
       "       [ 0.53500049,  0.46499951],\n",
       "       [ 0.40773979,  0.59226021],\n",
       "       [ 0.39156819,  0.60843181],\n",
       "       [ 0.15917245,  0.84082755],\n",
       "       [ 0.84442393,  0.15557607],\n",
       "       [ 0.85836793,  0.14163207],\n",
       "       [ 0.6676808 ,  0.3323192 ],\n",
       "       [ 0.86777235,  0.13222765],\n",
       "       [ 0.41606065,  0.58393935],\n",
       "       [ 0.68037609,  0.31962391],\n",
       "       [ 0.17364689,  0.82635311],\n",
       "       [ 0.52797399,  0.47202601],\n",
       "       [ 0.79411346,  0.20588654],\n",
       "       [ 0.83071671,  0.16928329],\n",
       "       [ 0.65749   ,  0.34251   ],\n",
       "       [ 0.46205002,  0.53794998],\n",
       "       [ 0.38874471,  0.61125529],\n",
       "       [ 0.60710156,  0.39289844],\n",
       "       [ 0.62219423,  0.37780577],\n",
       "       [ 0.94812725,  0.05187275],\n",
       "       [ 0.2693411 ,  0.7306589 ],\n",
       "       [ 0.95016632,  0.04983368],\n",
       "       [ 0.76216064,  0.23783936],\n",
       "       [ 0.48579976,  0.51420024],\n",
       "       [ 0.92922182,  0.07077818],\n",
       "       [ 0.72134227,  0.27865773],\n",
       "       [ 0.50084256,  0.49915744],\n",
       "       [ 0.39488351,  0.60511649],\n",
       "       [ 0.64566777,  0.35433223],\n",
       "       [ 0.41764836,  0.58235164],\n",
       "       [ 0.70226537,  0.29773463],\n",
       "       [ 0.68160518,  0.31839482],\n",
       "       [ 0.68739609,  0.31260391],\n",
       "       [ 0.85308867,  0.14691133],\n",
       "       [ 0.84293632,  0.15706368],\n",
       "       [ 0.60214206,  0.39785794],\n",
       "       [ 0.91823474,  0.08176526],\n",
       "       [ 0.80723401,  0.19276599],\n",
       "       [ 0.88300601,  0.11699399],\n",
       "       [ 0.27930968,  0.72069032],\n",
       "       [ 0.92373298,  0.07626702],\n",
       "       [ 0.58199276,  0.41800724]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred_proba"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0xd0e2ef0>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEACAYAAABMEua6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGVxJREFUeJzt3W+MZXd93/H317vGYBzvGBF2XFx21KjmTxRn6rTgCCRO\nACdL1cSW86AF1DIOSXgQ/ihpVFwpaKsUKeAHVkCURAmQMQ8glUgCNgm13bI/FRu8uN69eE2WDaQs\nYJKZGvPPzsoLG3/7YM7szs787txzz9wz35/P+bykK99z58783r539rez3zlzx9wdERHph4uiA0RE\nZHa0qYuI9Ig2dRGRHtGmLiLSI9rURUR6RJu6iEiPTNzUzewSMztiZsfM7LiZHapvP2Rmj5jZ0fpy\nsPtcERHZjjU5T93MLnX302a2B7gPeBvwWuBx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zn1kq8Yejpm36VeDTnRY1bDKzG83sBHAn8CvRTWb2T4Ab3f0P2L1NtOnz97P1\nP+H/stE/l7tvuhp4jpkdNrMHzOzfF9AEgJk9i7V/kf5ZAU3vB15iZn8HfBF4ewFNXwRuAjCzlwIv\nAK7a7oOG//CR5JnZzwE3A6+IbgFw908AnzCzVwDvAq4PTvp9YOMMcje/Ot7Og8AL3P20mb0W+ARr\nm2qkvcC1wKuAZwOfN7PPu/tXY7MA+EXgXncv4fUDfgE45u6vMrOfAO4xs2vc/YnApncD7zWzo8Bx\n4Bjwj9u9w6w29W+x9jfIuqvq2zbf559OuM8sNWnabY2azOwa4I+Ag+7+3RKa1rn7vWb2z8zsOe7+\nncCmfwn8qZkZa/PP15rZj9z9jo6aGnVt3ADc/dNm9oECHqtHgG+7+5PAk2b2v4GfZm2eG9W07t/R\n/egFmjXdDPwegLv/rZl9DXgR8H+imtz9cTb8y7hu+r/bftQZDfz3cH7g/wzWBv4v3nSff835b5Re\nR/ffAJzYtOG+h4D/2GXPFI/TC4CvANd13TNF009suH4t8M3opk33/xN25xulTR6r/RuuvxQ4VUDT\ni4B76vteytpXfC+Jfv5Y+wbuY8CzCnnu/htwaP15ZG008pzgpn3AxfX1XwOWJ37cGQYeZO0nTL8C\n3FLf9mbg1zfc5/31/8QXgWt34YnctmnDE/c94DvAN4DLgpv+uP5EP8raP7W+UMDj9J+Ah+um+4Cf\njW7adN8PswubesPH6jfqx+oY8DngZdFN9fFvs3YGzEPAWwtpeiPw0d143ho+d1cCd9WP0UOs/YR8\ndNN19dtPsHZSwL5JH1M/fCQi0iP6dXYiIj2iTV1EpEe0qYuI9Ig2dRGRHtGmLiLSI9rURUR6RJu6\niEiPaFMXEemR/w+Icv+FeLO0kwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xd0e2828>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "pd.Series(y_pred_proba[:,1]).hist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0xd0c6198>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEACAYAAACwB81wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEu5JREFUeJzt3W2MHed53vH/JdMy8mLKSlxRjWSbStXIktGUKVI6RQJ0\nkxqylMKUkA+CYtQ14xooqr5YKNCKDFCoH4rK/tIKRaACRo2QMRIoaoKUapJGtCouAheR5aCipYaM\nSqehorDWuoqtFGmRhkzufthZPWua1Bku5+zM2fP/AQecGc7hPr5M3jt7nTNHqSokSTvfNWMvQJK0\nPRz4krQkHPiStCQc+JK0JBz4krQkHPiStCR6DfwkZ5N8KcnzSZ7rjl2f5HiSl5I8leS6TecfTnIm\nyekkd85r8ZKk/vpe4f8ZsFJV31dV+7tjh4Cnq+o24BngMECSO4D7gNuBu4HHkmTYZUuSrlTfgZ9L\nnHsPcLTbPgrc220fAB6vqgtVdRY4A+xHkjSqvgO/gM8l+WKSj3fH9lTVGkBVvQrc0B2/CXhl03PP\ndcckSSPa1fO8H6yqryT5c8DxJC+x/k1gMz+jQZImrNfAr6qvdL/+ryT/gfWKZi3JnqpaS3Ij8NXu\n9HPAuzY9/ebu2DdI4jcISdqCqtrS66IzK50k35rk27vtbwPuBF4EngQOdqd9FDjWbT8J3J/k2iS3\nALcCz11m2aM+du/+EMeOHaOqRn08/PDDo69hKg+zMAuzePPH1ehzhb8H+KXuinwX8LNVdTzJbwJP\nJPkY8DLr78yhqk4leQI4BZwHHqirXeUOd/bs2bGXMBlm0ZhFYxbDmDnwq+p3gX2XOP414AOXec4j\nwCNXvTpJ0mC803YCDh48OPYSJsMsGrNozGIYGattWa+Ixm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HPAuzft39wdu/icd804\nZyfokwVJvhf4NHBXVb3Zj3SLrE8W3w88nvUPIH8ncHeS81X15Datcbv0yeL3gdeq6o+BP07y68Bf\nZr3v3kn6ZPETwCMAVfU7SX4XeC/wm9uywunY0tycd6XzReDWJO9Jci1wP3DxP9gngb8Nb9yh+3pV\nrc15XWOYmUWSdwO/CHykqn5nhDVul5lZVNV3d49bWO/xH9iBwx76/Rs5BvxQkrck+VbWX6Tbife1\n9MniZeADAF1n/T3A/9jWVW6fcPmfbLc0N+d6hV+XuQEryd9d/+36dFX9apIfTfJl4P+w/h18x+mT\nBfDPgO8AHuuubM9X1f7xVj0fPbP4hqds+yK3Sc9/I7+d5CngBeBPgU9X1akRlz0XPf9e/AvgyKa3\nK/7TqvraSEuemyQ/B6wA35nk94CHgWu5yrnpjVeStCT8TxxK0pJw4EvSknDgS9KScOBL0pJw4EvS\nknDgS9KScOBL0pJw4EvSkvj/+vlNxEiS4lgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xd1ff2e8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "all_data['target'].hist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.],\n",
       "       [ 0.,  1.],\n",
       "       [ 1.,  0.],\n",
       "       [ 1.,  0.]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.preprocessing import binarize\n",
    "\n",
    "y_pred_default = binarize(y_pred_proba, threshold=0.5)\n",
    "y_pred_default"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.,  1.,  0.,\n",
       "        0.,  1.,  0.,  1.,  0.,  0.,  0.,  1.,  1.,  0.,  0.,  1.,  0.,\n",
       "        0.,  0.,  0.,  1.,  1.,  1.,  0.,  0.,  1.,  0.,  0.,  1.,  0.,\n",
       "        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,\n",
       "        0.,  0.,  0.,  0.,  1.,  0.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,\n",
       "        0.,  0.,  1.,  0.,  1.,  1.,  0.,  0.,  1.,  0.,  1.,  1.,  0.,\n",
       "        0.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  1.,  0.,  1.,  0.,  0.,\n",
       "        0.,  0.,  0.,  0.,  1.,  1.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,\n",
       "        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  1.,  1.,  0.,\n",
       "        0.,  0.,  0.,  1.,  0.,  1.,  0.,  0.,  0.,  0.,  1.,  1.,  0.,\n",
       "        0.,  0.,  1.,  0.,  0.,  1.,  0.,  0.,  0.,  1.,  0.,  1.,  0.,\n",
       "        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.,  0.])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred_default[:,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[27, 27],\n",
       "       [12, 88]], dtype=int64)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics import confusion_matrix\n",
    "confusion_matrix(y_test, y_pred_default[:,1],labels = [1,0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[50,  4],\n",
       "       [48, 52]], dtype=int64)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred_low = binarize(y_pred_proba, threshold=0.2)\n",
    "confusion_matrix(y_test, y_pred_low[:,1],labels=[1,0]) #positive class is 1 again"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9285714285714286"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from __future__ import division \n",
    "def npv_func(th):\n",
    "    y_pred_low = binarize(y_pred_proba, threshold=th)\n",
    "\n",
    "    second_column = confusion_matrix(y_test, y_pred_low[:,1],labels=[1,0])[:,1]\n",
    "    npv = second_column[1]/second_column.sum()\n",
    "    return npv\n",
    "\n",
    "npv_func(0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\jdavila\\Anaconda27\\lib\\site-packages\\ipykernel\\__main__.py:6: RuntimeWarning: invalid value encountered in longlong_scalars\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0xd8b6940>]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEACAYAAABbMHZzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHuNJREFUeJzt3XmUlNWd//H3t1nEBVGUUQOyRDCuaJAgQdSSRRpEcTkq\nmKiJGyYaNToRSc78aCcZl8wZ4xq3cNREhSSuiMgSJ6XBqOCAQEwjjQgBQYNKGImDsnx/f9yCLtte\nqrur6tbyeZ1Tp+t56j5V33oOfJ9b97mLuTsiIlJeKmIHICIi+afkLyJShpT8RUTKkJK/iEgZUvIX\nESlDSv4iImWoyeRvZpPN7AMzW9xImTvNrMbM3jSzo9P2V5rZUjNbZmYTshW0iIi0TiY1/4eAEQ29\naGYjgYPcvQ8wHrgvtb8CuDt17OHAODM7pNURi4hIqzWZ/N19LrChkSJjgF+nyr4OdDKz/YABQI27\nr3L3LcDUVFkREYksG23+XYHVadtrUvsa2i8iIpHl4oav5eA9RUQki9pm4T3eAw5M2+6W2tce6F7P\n/nqZmSYZEhFpJndvUYU705q/0XCNfhpwAYCZDQT+4e4fAPOB3mbWw8zaA2NTZRvk7lEfn3/unHOO\nM3Sos2lTvDgmTZoU/VwUwkPnQedC56LxR2tk0tXzceDPwMFm9jcz+66ZjTezy1IJewbwrpktB+4H\nvp/avw24EpgNvAVMdffqVkWbY+3aweOPQ/fuMGIEbNwYOyIRkdxostnH3c/LoMyVDeyfCXytBXFF\n06YN/OpXcPXVMGQIzJoF++4bOyoRkezSCN96VFTAnXfCySfDiSfCunX5/fxEIpHfDyxQOg+1dC5q\n6Vxkh7W23ShbzMwLJZZ0N90EDz0Ef/gD9OgRO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16Edr9v1+CiR8y+z/yLDDYzNqY2W6Em3ul\nOHYmk3OxChgGkGrfPhhYkdco88to+Fdvs3Nn3mr+ntlgsRlmNsrMlgP/JFzZS04m5wL4N6Az8MtU\njXeLuw+IF3VuZHguvnBI3oPMkwz/jzQ4oLKUZPjv4mfAw2ndH693948jhZxTZvY4kAD2MbO/AZOA\n9rQid2qQl4hIGdIyjiIiZUjJX0SkDCn5i4iUISV/EZEypOQvIlKGlPxFRMqQkr+ISBlS8hcRKUP/\nH2mwVoL/aQGxAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xd603cc0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "ths = np.arange(0,1,0.05)\n",
    "\n",
    "npvs = []\n",
    "for th in np.arange(0,1.00,0.05):\n",
    "    npvs.append(npv_func(th)) \n",
    "    \n",
    "plt.plot(ths,npvs)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
